function getBreadCrumbData(elementId,breadCrumbMap) {
	var dropDownId = '#'+$(elementId).attr('name');
	var breadCrumbJSON = JSON.stringify(breadCrumbMap);
	console.log('breadCrumbMap'+breadCrumbMap);
	$.ajax({
		type : "POST",
		url : "/smart-1.0.0-BUILD-SNAPSHOT/getDimensionLevelData",
		data : breadCrumbJSON,
		contentType: 'application/json',
		dataType : 'json',
		success : function(data){
			if(data!=null){
				console.log("JSON-Output:"+data);
				populateDropDown(dropDownId,data);
			}									
		}			
	});
}

function getCustomizedConsumptionReport(breadCrumbMap,chartNumber,xAxisLevel) {
	var breadCrumbJSON = JSON.stringify(breadCrumbMap);
	var dimensionData = new Object();
	var index = 0;
	var graphChartLabel = null;
	
	if(chartNumber==1) {
		graphChartLabel = 'GEOGRAPHY';
	} else if (chartNumber==2) {
		graphChartLabel = 'SUBSTATION';
	} else if (chartNumber==3) {
		graphChartLabel = 'CUSTOMER';
	} else {
		graphChartLabel = 'ERROR';
	}
	
	$.ajax({
		type : "POST",
		url : "/smart-1.0.0-BUILD-SNAPSHOT/getCustomizedConsumptionReport",
		data : breadCrumbJSON,
		contentType: 'application/json',
		dataType : 'json',
		success : function(data){
			if(data!=null){		
				console.log("JSON-Input:"+JSON.stringify(data));
				processCustomizedResponse(chartNumber,data);	
				showCustomizedChart(chartNumber, 'ctzchart-'+chartNumber, graphChartLabel, xAxisLevel, chart3xAxisPoints, chart3xAxisValues);
			}									
		}					
	});
}

function getCustomizedAlarmReport(breadCrumbMap,chartNumber,xAxisLevel) {
	//alert('insert into getCustomizedAlarmReport method....');
	var breadCrumbJSON = JSON.stringify(breadCrumbMap);
	var dimensionData = new Object();
	var index = 0;
	var graphChartLabel = null;
	
	if(chartNumber==1) {
		graphChartLabel = 'GEOGRAPHY';
	} else if (chartNumber==2) {
		graphChartLabel = 'TYPE';
	} else if (chartNumber==3) {
		graphChartLabel = 'SEVERITY';
	} else {
		graphChartLabel = 'ERROR';
	}
	
	$.ajax({
		type : "POST",
		url : "/smart-1.0.0-BUILD-SNAPSHOT/getCustomizedAlarmReport",
		data : breadCrumbJSON,
		contentType: 'application/json',
		dataType : 'json',
		success : function(data){
			if(data!=null){		
				console.log("JSON-Input:"+JSON.stringify(data));
				processCustomizedResponse(chartNumber,data);	
				showCustomizedChart(chartNumber, 'ctzchart-'+chartNumber, graphChartLabel, xAxisLevel, chart3xAxisPoints, chart3xAxisValues);
			}									
		}					
	});
}

function getComparisonConsumptionReport(breadCrumbMap,chartNumber,xAxisLevel) {
	var breadCrumbJSON = JSON.stringify(breadCrumbMap);
	var dimensionData = new Object();
	var index = 0;
	var graphChartLabel = null;
	
	if(chartNumber==1) {
		graphChartLabel = 'GEOGRAPHY';
	} 
	
	$.ajax({
		type : "POST",
		url : "/smart-1.0.0-BUILD-SNAPSHOT/getComparisonConsumptionReport",
		data : breadCrumbJSON,
		contentType: 'application/json',
		dataType : 'json',
		success : function(data){
			if(data!=null){		
				console.log("JSON-Input:"+JSON.stringify(data));
				processComparisonResponse(chartNumber,data);	
				showComparisonChart(1, 'chart_1', graphChartLabel, xAxisLevel, chart1Label, chart1xAxisPoints, chart1xAxisValues, chart2Label, chart2xAxisPoints, chart2xAxisValues)
			}									
		}					
	});
}

function processCustomizedResponse(chartNumber,data) {
	console.log("processCustomizedResponse-"+chartNumber+":"+JSON.stringify(data));
	var index = 0;
	chart3xAxisPoints.length = 0; 
	chart3xAxisValues.length = 0; 	
	
	for (var key in data) {
		if (chartNumber==1) {
			chart1xAxisPoints[index]=key;
			chart1xAxisValues[index]=data[key];
		} else if (chartNumber==2) {
			chart2xAxisPoints[index]=key;
			chart2xAxisValues[index]=data[key];
		} 
		chart3xAxisPoints[index]=key;
		chart3xAxisValues[index]=data[key];
		index++;
	}
}

function processComparisonResponse(chartNumber,data) {
	console.log("processComparisonResponse-"+chartNumber+":"+JSON.stringify(data));
	var index = 0;
	chart3xAxisPoints.length = 0; 
	chart3xAxisValues.length = 0; 	
	var suffix = null;
	
	for (var series in data) {
		index = 0;
		suffix = series.substring(series.lastIndexOf('_')+1);
		//alert(series);
		for(var key in data[series]) {
			//alert("Data:"+key+ " :Value: "+data[series][key]);
			if (suffix == "FROM") {
				//chart1Label = series;
				chart1Label = getBreadCrumbLabelString(series);
				chart1xAxisPoints[index]=key;
				chart1xAxisValues[index]=data[series][key];
				index++;
			} else if (suffix == "TO") {
				//chart2Label = series;
				chart2Label = getBreadCrumbLabelString(series);
				chart2xAxisPoints[index]=key;
				chart2xAxisValues[index]=data[series][key];
				index++;
			} 		
		}		
	}
}
